import request from "@/utils/request";


/**
 * 提交订单
 * @param params
 */
export const createOrder = (params) => {
  return request.post("/order/createOrder", params);
};

/**
 * 查询订单
 * @param params
 */
export const getOrder = (orderSn) => {
  return request.get(`/order/getOrder?orderSn=${orderSn}`);
};

export function getOrderList(params) {
  return request.post(`/order/orderList`, params);
}

/**
 * 订单明细
 * @param {orderSn} 订单编号
 */
export function orderDetail(orderSn) {
  return request.get(`/order/detail/${orderSn}`);
}

/**
 * 取消订单
 * @param {orderSn} 订单编号
 * @param reason 取消订单原因
 */
export function cancelOrder(orderSn) {
  return request.post(`/order/cancel/${orderSn}`);
}

/**
 * 删除订单
 * @param {orderSn} 订单编号
 */
export function deleteOrder(orderSn) {
  return request.get(`/order/delete/${orderSn}`);
}


/**
 * 卖家-查询订单列表
 * @param params
 */
export function querySellOrder(params) {
  return request.post(`/order/querySellOrder`, params);
}

/**
 * 卖家-订单详情
 * @param params
 */
export function sellOrderDetail(orderSn) {
  return request.get(`/order/sellOrderDetail/${orderSn}`);
}

// 添加评价
export function addEvaluation(params) {
  return request.post(`/order/addEvaluation`, params);
}

// 添加回复
export const addEvaluationReply = (params) => {
  return request.post(`/order/addEvaluationReply`, params);
};

/**
 * 获取商品购买记录
 * @param params
 */
export function getGoodsPurchased(goodsId) {
  return request.get(`/order/getGoodsPurchased?goodsId=${goodsId}`);
}

export const deleteEvaluation = (evaluationId) => {
  return request.get("/order/deleteEvaluation?evaluationId=" + evaluationId);
};
